package com.groupname.dangerousdelves;

import java.io.InputStreamReader;
import java.io.BufferedReader;
import android.content.SharedPreferences;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import android.preference.PreferenceManager;
import java.io.IOException;
import java.io.File;
import android.os.Environment;
import android.content.Context;
import android.content.res.AssetManager;
import java.io.InputStream;
import java.io.OutputStream;

// -------------------------------------------------------------------------
/**
 * Write a one-sentence summary of your class here. Follow it with additional
 * details about its purpose, what abstraction it represents, and how to use it.
 *
 * @author Chris Fieldman
 * @version 2012.11.17
 */
public class AndroidFileIO
    implements FileIO
{
    // ~-------------------------------------------------------------------------
    // Member Variables
    private Context      context;
    private AssetManager assets;
    private String       externalStoragePath;


    // ~-------------------------------------------------------------------------
    // Constructors
    /**
     * Create a new FileIO object.
     *
     * @param newContext
     *            The context for this object
     */
    public AndroidFileIO(Context newContext)
    {
        this.context = newContext;
        this.assets = context.getAssets();
        this.externalStoragePath =
            Environment.getExternalStorageDirectory().getAbsolutePath()
                + File.separator;
    }


    // ~-------------------------------------------------------------------------
    // Methods
    public BufferedReader readAsset(String fileName)
        throws IOException
    {
        return new BufferedReader(new InputStreamReader(assets.open(fileName)));
    }
}
